package com.kongj18.mrio.controller;

import com.kongj18.mrio.domain.ResultExport;
import com.kongj18.mrio.service.ResultExportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(path = "resultExport")
public class ResultExportController {
    @Autowired
    private ResultExportService service;

    @RequestMapping(path = "findByProvinceAndItem")
    @ResponseBody
    public List<ResultExport> findByProvinceExportAndItem(@RequestParam String provinceName, @RequestParam String itemName){
        return service.findByProvinceExportAndItem(provinceName, itemName);
    }

    @RequestMapping(path = "findByProvinceExportListAndItem")
    @ResponseBody
    public List<ResultExport> findByProvinceExportListAndItem(@RequestParam(value = "provinces[]") List<String> provinces, @RequestParam String itemName){
        return service.findByProvinceExportListAndItem(provinces, itemName);
    }

    @RequestMapping(path = "findByProvinceImportListAndItem")
    @ResponseBody
    public List<ResultExport> findByProvinceImportListAndItem(@RequestParam(value = "provinces[]") List<String> provinces, @RequestParam String itemName){
        return service.findByProvinceImportListAndItem(provinces, itemName);
    }

    @RequestMapping(path = "getAll")
    @ResponseBody
    public List<ResultExport> getAll(){
        return service.getAll();
    }
}
